const db = require('mongoose');
const Paginate = require('mongoose-paginate-v2');

var userSchema = new db.Schema({
	username: { type: String, require: true },
	password: { type: String, require: true },
	role: {
		type: String,
		require: true
	}//,
	//user: [{
	//	type: db.Schema.Types.ObjectId,
	//	ref: "Pengguna"
	//}]
}, {
	timestamps: true
})

var bookmarkSchema = new db.Schema({
	url: { type: String, require: true },
	judul: String,
	uraian: String,
	tags: [{ type: String }],
	user: String,
	nanti: String 
}, {
	timestamps: true
})

var noteSchema = new db.Schema({
	judul: String,
	isi: String
}, { timestamps: true})

bookmarkSchema.plugin(Paginate)

var bookmark = db.model('bookmark', bookmarkSchema);
var user = db.model('user', userSchema);
var notes = db.model('notes', noteSchema);

module.exports = {
	bookmark : bookmark,
	pengguna : user,
	notes: notes
};
